package com.lizhe.async.task;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

/**
 * 类描述: 线程池执行 异步任务
 *
 * @author Lz on 2021-11-15
 */
@Component
public class AsyncExecutorTask extends AbstractTask {


    @Async("taskExecutor")
    public void doTaskOneCallback() throws InterruptedException {
        super.doTaskOne();
        System.out.println("任务一，当前线程：" + Thread.currentThread().getName());
        new AsyncResult<>("任务一完成");
    }

    @Async("taskExecutor")
    public void doTaskTwoCallback() throws InterruptedException {
        super.doTaskTwo();
        System.out.println("任务二，当前线程：" + Thread.currentThread().getName());
        new AsyncResult<>("任务二完成");
    }


    @Async("taskExecutor")
    public void doTaskThreeCallback() throws InterruptedException {
        super.doTaskThree();
        System.out.println("任务三，当前线程：" + Thread.currentThread().getName());
        new AsyncResult<>("任务三完成");
    }
}
